import { makeAutoObservable } from "mobx";
import { http, setToken, getToken } from "../utils";
import { removeToken } from "../utils";

class LoginStore {
  token = getToken() || "";
  constructor() {
    makeAutoObservable(this);
  }
  // 246810
  getToken = ({ mobile, code }) => {
    http
      .post("http://geek.itheima.net/v1_0/authorizations", { mobile, code })
      .then((res) => {
        console.log(res.data.data.token);
        this.token = res.data.data.token;
        setToken(this.token);
      });
  };
  // 退出登录
  loginOut = () => {
    removeToken()
    this.token = ''
  }
}

export default LoginStore;
